home *** CD-ROM | disk | FTP | other *** search
- Path: cs.umd.edu!gilman
- From: gilman@cfar.umd.edu (Gil Carmel)
- Newsgroups: comp.lang.c++
- Subject: Re: Template Class Linkage?
- Date: 8 Jan 1996 19:03:24 GMT
- Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742
- Message-ID: <4crpps$7ni@mimsy.cs.umd.edu>
- References: <4cmnjs$mk7@mimsy.cs.umd.edu> <4cq4hs$raa@news2.deltanet.com>
- NNTP-Posting-Host: scribble.cfar.umd.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
- Sergio Olivas (olivas@deltanet.com) wrote:
-
- : >I'm just learning templates, and I'm having problems with linkage.
- : >When the template class member function bodies are included in the .h file,
- : >everything is fine. But when the function bodies are in a separate .c file,
- : >calls to these functions from other files give an "undefined reference to
- : >function" error from the linker. Do template class member functions have
- : >to be in the ".h" file, or is this a problem with my compiler?
-
- : Yes, this is a known 'feature' of C++ -- As far as the language
- : standard and all the compilers go. I understand an update to the C++
- : language will include some way of including the template stuff into
- : the .c (cpp) files, as well as provide the Standard Template library
- : as part of the language.
-
- : later,
- : sergio
-
- Thanks. One more question:
- What happens if two different files use the same template class function?
- If both need to include the function body, then it will be defined twice and
- the linker will produce an error.
-
- Gil
-
- --
- |-----------------------------------------------------------|
- | Gil Carmel | gilman@wam.umd.edu |
- | Computer Science Undergraduate | gilman@cfar.umd.edu |
- | University of Maryland | |
- | College Park, MD | |
- |-----------------------------------------------------------|
- | | \o | |
- | | |\ | |
- | | / \ | |
-